package main

import (
	"net/http"
	"net"
	"fmt"
	"os"
	"strings"
	"dockerCi/dockerCi"
)

//调用docker
func ShowDocker(w http.ResponseWriter,req *http.Request)  {
	runDocker:=&dockerCi.DockerCi{"hanmeimei"}
	fmt.Fprint(w,runDocker.Say())
}


//返回本机IP地址
func GetIP() string {
	conn, err := net.Dial("udp", "baidu.com:80")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(-1)
	}
	defer conn.Close()
	return strings.Split(conn.LocalAddr().String(), ":")[0]
}


//提供简单的web 应用
func main()  {
	ip:=GetIP()
	http.HandleFunc("/",ShowDocker)
	fmt.Println("Server Started at:"+ip+":7070")
	err:=http.ListenAndServe(ip+":7070",nil)
	if(err!=nil){
		fmt.Println("Server started errorr:",err.Error())
	}
}
